<template>
  <div class="goods-box">
    <div class="goods-head">
      <div class="goods-head-img">
        <img :src="goodsItem.imgUrl" />
      </div>
      <div class="goods-head-info">
        <h3>{{ goodsItem.name }}</h3>
        <div class="sell-and-rate">
          <span>月售{{ goodsItem.sellCount }}份</span>
          <span>好评率{{ goodsItem.rating }}%</span>
        </div>

        <div class="price-and-car">
          <p class="price">￥{{ parseFloat(goodsItem.price).toFixed(2) }}元</p>
          <van-button round color="#ffc300">
            <h4>加入购物车</h4>
          </van-button>
        </div>
      </div>
    </div>
    <div class="goods-center">
      <p>商品介绍</p>
      <p>{{ goodsItem.goodsDesc }}</p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      goodsItem: [], //某个商品列表的详情信息
    };
  },
  created() {
    this.goodsItem = this.$route.query;
    console.log(this.goodsItem);
  },
};
</script>

<style lang="less" scoped>
.goods-box {
  width: 100%;
  height: 100%;
  background-color: #f4f5f7;
  .goods-head {
    background-color: #fff;
    .goods-head-img {
      img {
        width: 100%;
        height: 300px;
      }
    }
    .goods-head-info {
      padding: 8px 10px;
      h3 {
        font-size: 22px;
      }
      .sell-and-rate {
        padding-top: 6px;
        color: gray;
        font-size: 15px;
        span {
          padding-right: 10px;
        }
      }
      .price-and-car {
        display: flex;
        justify-content: space-between;
        .price {
          font-size: 24px;
          color: red;
          padding-top: 4px;
        }

        .van-button {
          h4 {
            color: black;
            font-size: 16px;
          }
        }
      }
    }
  }
  .goods-center {
    margin-top: 20px;
    background-color: #fff;
    padding: 16px;
    p:nth-child(1) {
      font-size: 22px;
    }
    p:nth-child(2) {
      padding-top: 8px;
      font-size: 18px;
    }
  }
}
</style>